<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Admin.Master"Inherits="System.Web.Mvc.ViewPage<DIS_WEB_Client.ViewModels.GroupViewModel>" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	SelectItem
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent1" runat="server">
	<span class="AdminTitle" style="color:#cc0000;">Item Management</span>
	(<a href="<%= Url.Action("Index", "Home") %>" class="AdminPageText">
	<%= WebConfiguration.SiteName  %>
	</a>|
	<a href="<%= Url.Action("LogOff", "Account") %>" class="AdminPageText">
		LogOut
	</a>)
	<br />
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent2" runat="server">
	<script type="text/javascript">
		<% if (Model.ItemModel.InfoText != null && Model.ItemModel.InfoText != ""){ %>
			alert('<%= Model.ItemModel.InfoText %>');
		<% } %>
	</script>
    <script type="text/javascript">
        function ValidateUpdate() {
            var promotion = document.getElementsByName("Item_Promotion").item(0);
            if (promotion.value == "") {
                alert("Please input promotion");
                return false;
            }
            if (isNaN(promotion.value)){
                alert("Promotion must be a numeric");
                return false;
            }
            var nationalpromotion = document.getElementsByName("Item_NationalPromotion").item(0);
            if (parseFloat(promotion.value) <= parseFloat(nationalpromotion.value)) {
                alert("Local promotion must be lager than national promotion");
                return false;
            }
            return true;
        }
    </script>
	<% using (Html.BeginForm("UpdateItem", "Admin", FormMethod.Post, new { onsubmit = "return ValidateUpdate();" }))
	{ %>
		<div style="padding-top: 40px">
			<span style="font-size:18px; font-weight:bold;">DetailOf Item</span>
			<table width="100%" border="0" cellspacing="0" cellpadding="0" class="AdminPageText">
				<tbody>
					<tr>
						<td>
							<div align="left" style="padding-top:15px">
								<font class="normal8">Name: </font>
							</div>
						</td>
						<td height="20">
							<div align="left" style="padding-top:15px">
								<%= Model.ItemModel.GetModel.LstObjModel[0].Name %>
							</div>
						</td>
					</tr>
					<tr>
						<td>
							<div align="left" style="padding-top:15px">
								<font class="normal8">Price: </font>
							</div>
						</td>
						<td height="20">
							<div align="left" style="padding-top:15px">
								<%= Model.ItemModel.GetModel.LstObjModel[0].Price %>
							</div>
						</td>
					</tr>
					<tr>
						<td>
							<div align="left" style="padding-top:15px">
								<font class="normal8">Image: </font>
							</div>
						</td>
						<td height="20">
							<div align="left" style="padding-top:15px">
								<img src="<%= Url.Action("ShowItemImage", "Image", new { idItem = Model.ItemModel.GetModel.LstObjModel[0].ID })%>" width="120px" height="120px" />
							</div>
						</td>
					</tr>
                    <%
                        var nationalPromotion = Model.NationalPromotionModel.GetModel.LstObjModel.Count == 0 ? null : Model.NationalPromotionModel.GetModel.LstObjModel[0];
                        var onlinewarehouse = Model.ChemistWareHouseModel.GetModel.LstObjModel[0];
                        var localPromotion = Model.LocalPromotionModel.GetModel.LstObjModel.Count == 0 ? null : Model.LocalPromotionModel.GetModel.LstObjModel[0];
                     %>
                    <tr>
						<td>
							<div align="left" style="padding-top:15px">
								<font class="normal8">National Promotion: </font>
							</div>
						</td>
						<td height="20">
							<div align="left" style="padding-top:15px">
								<%= nationalPromotion == null ? 0 : nationalPromotion.Discount %> %
                                <input type="hidden" name="Item_NationalPromotion" value="<%= nationalPromotion == null ? 0 : nationalPromotion.Discount %>" />
							</div>
						</td>
					</tr>
                    <tr>
						<td>
							<div align="left" style="padding-top:15px">
								<font class="normal8">Local Promotion: </font>
							</div>
						</td>
						<td height="20">
							<div align="left" style="padding-top:15px">
                                <%= Html.TextBox("Item_Promotion", localPromotion == null ? 0 : localPromotion.Discount, new { @style = "width: 40px;" })%> %
							</div>
						</td>
					</tr>
					<tr>
						<td height="20" style="width: 130px">
						</td>
						<td height="20">
							<div align="left">
								<br/>
                                <input type="hidden" name="Item_ID" value="<%= Model.ItemModel.GetModel.LstObjModel[0].ID %>" />
								<input type="submit" value="Update" />
								<p>
								</p>
							</div>
						</td>
					</tr>
				</tbody>
			</table>
		</div>
	<% } %>
</asp:Content>
